package progress.exa27_7;

import java.util.ArrayDeque;

public class ArrayDequeStudy {

    public static void main(String[] args) {
        FIFOTest();
        LIFOTest();
    }

    /**
     * 先进先出测试
     */
    public static void FIFOTest(){
        ArrayDeque<Integer> queue = new ArrayDeque<>();
        System.out.println("将0-99按顺序放入队列中");
        for(int i=0;i<100;i++){
            queue.addLast(i);
        }
        System.out.println(queue.size());
        System.out.println("取出10个元素： ");
        for(int i=0;i<10;i++){
            System.out.print(queue.poll()+" ");
        }
        System.out.println("队列大小： ");
        System.out.println(queue.size());
    }

    /**
     * 后进先出测试
     */
    public static void LIFOTest(){
        ArrayDeque<Integer> queue = new ArrayDeque<>();
        System.out.println("将0-99按顺序放入栈中");
        for(int i=0;i<100;i++){
            queue.addFirst(i);
        }
        System.out.println(queue.size());
        System.out.println("取出10个元素： ");
        for(int i=0;i<10;i++){
            System.out.print(queue.poll()+" ");
        }
        System.out.println("栈大小： ");
        System.out.println(queue.size());
    }

}
